export function queryString(keyValue) {
  var search = location.search.replace('?', '');

  var list = search.split('&');

  list = list.map((content) => {
    var key = content.split('=')[0];
    var value = content.split('=')[1];
    return { key, value }
  })

  var [obj] = list.filter(({ key }) => key === keyValue);
  return obj ? obj.value : '';
}

// 设置cookie
export function setCookie(name, content, iDay = 7) {
  var date = new Date();
  date.setDate(date.getDate() + iDay);
  date.setHours(date.getHours() - 8);
  document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(content)};path=/;expires=${date}`
}
// 删除cookie
export function removeCookie(name) {
  setCookie(name, '', -1);
}
// 获取cookie对象
export function getAllCookie() {
  var cookie = document.cookie;
  var list = cookie.split('; ');
  return list.reduce(function (total, value) {
    total[value.split('=')[0]] = value.split('=')[1]
    return total;
  }, {});
}
// 获取特定的cookie
export function getCookie(name) {
  return getAllCookie()[encodeURIComponent(name)] ? decodeURIComponent(getAllCookie()[encodeURIComponent(name)]) : '';
}